# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=yeti
pkgver=3427.42c9e28c
pkgrel=1
pkgdesc='A platform meant to organize observables, indicators of compromise, TTPs, and knowledge on threats in a single, unified repository.'
groups=('blackarch' 'blackarch-defensive' 'blackarch-recon')
arch=('any')
url='https://github.com/yeti-platform/yeti'
license=('Apache')
depends=('python' 'python-chardet' 'python-click' 'python-click-plugins'
         'python-colorama' 'python-cssselect' 'python-dnspython'
         'python-docutils' 'python-flask' 'python-flask-classy' 'python-pytz'
         'python-flask-login' 'python-flask-mongoengine' 'python-pyopenssl'
         'python-flask-negotiation' 'python-flask-wtf' 'python-future'
         'python-geoip2' 'python-python-whois' 'python-html2text'
         'python-idna' 'python-imagesize' 'python-ipaddr' 'python-iptools'
         'python-ipwhois' 'python-itsdangerous' 'python-jinja'
         'python-kombu' 'python-libmagic' 'python-lxml' 'python-maclookup'
         'python-markupsafe' 'python-maxminddb' 'python-mongoengine'
         'python-packaging' 'python-pdfkit' 'python-psutil' 'python-celery'
         'python-pdfminer' 'python-pygments' 'python-pymongo' 'redis' 'mongodb'
         'python-pyparsing' 'python-pysocks' 'python-dateutil' 'wkhtmltopdf'
         'python-shodan' 'python-magic' 'python-readability-lxml' 'libxml2'
         'python-redis' 'python-requests-file' 'python-simplejson'
         'python-six' 'python-sphinx' 'python-snowballstemmer'
         'python-urllib3' 'python-werkzeug' 'python-sphinxcontrib-httpdomain'
         'python-sphinxcontrib-websupport' 'python-sphinx_rtd_theme'
         'python-tldextract' 'python-typing' 'python-urlnorm' 'python-vine'
         'python-wtforms' 'python-xlsxwriter' 'python-yara-python-dex'
         'python-url-normalize' 'python-pandas' 'python-flask-api' 'libxslt')
makedepends=('git' 'yarn')
source=("git+https://github.com/yeti-platform/$pkgname.git")
sha512sums=('SKIP')
install="$pkgname.install"

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  yarn install --non-interactive

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm *.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

